package com.cweb.framework.pojo;

import com.cweb.framework.util.ErrorEnum;

/**
 * 共通的自定义异常类
 */
public class CustomException extends Exception {

    private static final long serialVersionUID = -7284990650053367302L;

    public CustomException(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public CustomException(ErrorEnum code) {
        this.code = code.getCode();
        this.message = code.getMsg();
    }

    public CustomException(ErrorEnum code, String message) {
        this.code = code.getCode();
        if (null != message) {
            this.message = message;
        } else {
            this.message = code.getMsg();
        }

    }

    private String code;
    private String message;
    private String detail;

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
